import QtQuick 2.1
import QtQuick.Layouts 1.0
import QtQuick.Controls 1.0
import QtQuick.Controls.Styles 1.0
import org.qtproject.qtquick 1.0
import "qrc:/js/resource/Constants.js" as Constant

//import "page"

ApplicationWindow {
    id : id_mainWindow

    width: Constant.width * m_ratio;
    height: Constant.height * m_ratio;

    //=======================property===========================
    property real m_ratio: ApplicationInfo.ratio;

    //=======================function===========================
    function onShowMainPage() {
        id_pageView.pop();
        id_pageView.push(Qt.resolvedUrl("page/MainPage.qml"));
    }

    //=======================content============================
    StackView {
        id: id_pageView
        anchors.fill: parent
        focus: true

        delegate: StackViewDelegate {
            pushTransition: StackViewTransition {
                function transitionFinished(properties)
                {
                    properties.exitItem.opacity = 1
                }
                PropertyAnimation {
                    target: enterItem
                    property: "x"
                    from: target.width
                    to: 0
                    duration: 500
                    easing.type: Easing.OutSine
                }
                PropertyAnimation {
                    target: exitItem
                    property: "x"
                    from: 0
                    to: -target.width
                    duration: 500
                    easing.type: Easing.OutSine
                }
            }
            popTransition: StackViewTransition {
                function transitionFinished(properties)
                {
                    properties.exitItem.opacity = 1
                }
                PropertyAnimation {
                    target: enterItem
                    property: "x"
                    from: -target.width
                    to: 0
                    duration: 500
                    easing.type: Easing.OutSine
                }
                PropertyAnimation {
                    target: exitItem
                    property: "x"
                    from: 0
                    to: target.width
                    duration: 500
                    easing.type: Easing.OutSine

                }
            }
            property Component replaceTransition: pushTransition
        }
    }
    //========================================================
    Component.onCompleted: {
        ApplicationInfo.showMainPage.connect(onShowMainPage);

        ApplicationInfo.initData();
    }
}

